using System;
using System.Collections.Generic;
using System.Text;

namespace BlackJackSimulator
    {
    public class PlayerMatrix
        {
        private int mPlayerMatrixID;
        public DataSets.PlayerActionMatrix.ActionMatrixDataTable dtPlayerMatrix = new DataSets.PlayerActionMatrix.ActionMatrixDataTable();
        DataSets.PlayerActionMatrix.ActionMatrixRow drwPlayerMatrixAction;
        public DataSets.PlayerActionMatrix.ActionMatrix_2DataTable dtPlayerMatrix_2 = new BlackJackSimulator.DataSets.PlayerActionMatrix.ActionMatrix_2DataTable();
        DataSets.PlayerActionMatrix.ActionMatrix_2Row drwPlayerMatrixAction_2;

        private string[] m_strPlayerShows = new string[32];

        public int PlayerMatrixID
            {
            get
                {
                return mPlayerMatrixID;
                }
            set
                {
                mPlayerMatrixID = value;
                }
            }
        
        public enum PlayerActions
            {
            Hit=1,Stay=2,Split=3,Double=4
            }
        private void CreatePlayerShowsArray()
            {
            
            }
        public void SetUp_2()
            {

            for (int intPlayerShowsCounter = 2; intPlayerShowsCounter < 22; intPlayerShowsCounter++)
                {
                m_strPlayerShows[intPlayerShowsCounter] = intPlayerShowsCounter.ToString();
                }
          
            m_strPlayerShows[22] = "2,2";
            m_strPlayerShows[23] = "3,3";
            m_strPlayerShows[24] = "4,4";
            m_strPlayerShows[25] = "5,5";
            m_strPlayerShows[26] = "6,6";
            m_strPlayerShows[27] = "7,7";
            m_strPlayerShows[28] = "8,8";
            m_strPlayerShows[29] = "9,9";
            m_strPlayerShows[30] = "T,T";
            m_strPlayerShows[31] = "A,A";

            dtPlayerMatrix_2 = new BlackJackSimulator.DataSets.PlayerActionMatrix.ActionMatrix_2DataTable();
            for (int intPlayerShowsCounter = 2; intPlayerShowsCounter < 32; intPlayerShowsCounter++)
                {
                drwPlayerMatrixAction_2 = dtPlayerMatrix_2.NewActionMatrix_2Row();
                drwPlayerMatrixAction_2.PlayerShows = m_strPlayerShows[intPlayerShowsCounter];
                dtPlayerMatrix_2.AddActionMatrix_2Row(drwPlayerMatrixAction_2);
                }



            }
        public void SetUp()
            {

            for (int intDealerShows = 1; intDealerShows <= 10; intDealerShows++)
                {
                for (int intPlayerShows = 2; intPlayerShows < 17; intPlayerShows++)
                    {
                    dtPlayerMatrix.AddActionMatrixRow(intDealerShows,intPlayerShows,(int)PlayerActions.Hit);
                    }
                }

            for (int intDealerShows = 1; intDealerShows <= 10; intDealerShows++)
                {
                for (int intPlayerShows = 17; intPlayerShows < 22; intPlayerShows++)
                    {
                    dtPlayerMatrix.AddActionMatrixRow(intDealerShows,intPlayerShows,(int)PlayerActions.Stay);
                    }
                }

            }

        public string DeterminePlayerAction(string DealerShows,string PlayerShows,PlayerMatrix PlayerMatrixToUse)
            {
            try
                {
                if (DealerShows == "10") { DealerShows = "T"; }
                if (DealerShows == "1") { DealerShows = "A"; }
                if (PlayerShows == "10,10") { PlayerShows = "T,T"; }
                if (PlayerShows == "1,1") { PlayerShows = "A,A"; }
                drwPlayerMatrixAction_2 = (DataSets.PlayerActionMatrix.ActionMatrix_2Row)PlayerMatrixToUse.dtPlayerMatrix_2.Select("PlayerShows = '" + PlayerShows + "'")[0];

                string ReturnAction = "";
                ReturnAction = drwPlayerMatrixAction_2[DealerShows].ToString();

                return ReturnAction;
                }
            catch (Exception err)
                {
                return "";
                }


            }



        }

    }
